﻿package net.wangit.jdbc.type;

import net.wangit.Row;
import net.wangit.jdbc.Type;

public final class TypeFactory {
	public static final Type getType(Row row) {
		int type = row.getInt("dt", -1);
		switch (type) {
		case Type.CHAR:
			return new CharType(row);
		case Type.VARCHAR:
			return new VarcharType(row);
		case Type.SMALLINT:
			return new SmallintType();
		case Type.INTEGER:
			return new IntegerType();
		case Type.BIGINT:
			return new BigintType();
		case Type.FLOAT:
			return new FloatType();
		case Type.DOUBLE:
			return new DoubleType();
		case Type.DECIMAL:
			return new DecimalType(row);
		case Type.DATE:
			return new DateType();
		case Type.TIME:
			return new TimeType();
		case Type.TIMESTAMP:
			return new TimestampType();
		case Type.CLOB:
			return new ClobType(row);
		case Type.BLOB:
			return new BlobType(row);
		}
		throw new UnsupportedOperationException("Unsupported type: " + type);
	}
}